package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PersonOtherInfo;
import com.ruoyi.system.service.IPersonOtherInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其余相关信息Controller
 * 
 * @author TYF
 * @date 2023-08-12
 */
@Controller
@RequestMapping("/system/otherInfo")
public class PersonOtherInfoController extends BaseController
{
    private String prefix = "system/otherInfo";

    @Autowired
    private IPersonOtherInfoService personOtherInfoService;

    @RequiresPermissions("system:otherInfo:view")
    @GetMapping("/NotInBase")
    public String otherInfoNotInBase()
    {
        return prefix + "/otherInfoNotInBase";
    }


    @RequiresPermissions("system:otherInfo:view")
    @GetMapping("/InBase")
    public String otherInfoInBase()
    {
        return prefix + "/otherInfoInBase";
    }


    @RequiresPermissions("system:otherInfo:view")
    @GetMapping("/otherInfoBase")
    public String otherInfoBase()
    {
        return prefix + "/otherInfoBase";
    }

    /**
     * 查询其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:list")
    @PostMapping("/NotInBaseList")
    @ResponseBody
    public TableDataInfo NotInBaseList(PersonOtherInfo personOtherInfo)
    {
        startPage();
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoNotInBaseList(personOtherInfo);
        return getDataTable(list);
    }


    /**
     * 查询其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:list")
    @PostMapping("/InBaseList")
    @ResponseBody
    public TableDataInfo InBaseList(PersonOtherInfo personOtherInfo)
    {
        startPage();
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoInBaseList(personOtherInfo);
        return getDataTable(list);
    }



    /**
     * 查询其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:list")
    @PostMapping("/otherInfoBase")
    @ResponseBody
    public TableDataInfo otherInfoBase(PersonOtherInfo personOtherInfo)
    {
        startPage();
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoBaseList(personOtherInfo);
        return getDataTable(list);
    }

    /**
     * 导出其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:export")
    @Log(title = "其余相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/exportNotInBase")
    @ResponseBody
    public AjaxResult exportNotInBase(PersonOtherInfo personOtherInfo)
    {
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoNotInBaseList(personOtherInfo);
        ExcelUtil<PersonOtherInfo> util = new ExcelUtil<PersonOtherInfo>(PersonOtherInfo.class);
        return util.exportExcel(list, "其余相关信息数据");
    }



    /**
     * 导出其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:export")
    @Log(title = "其余相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/exportInBase")
    @ResponseBody
    public AjaxResult exportInBase(PersonOtherInfo personOtherInfo)
    {
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoInBaseList(personOtherInfo);
        ExcelUtil<PersonOtherInfo> util = new ExcelUtil<PersonOtherInfo>(PersonOtherInfo.class);
        return util.exportExcel(list, "其余相关信息数据");
    }


    /**
     * 导出其余相关信息列表
     */
    @RequiresPermissions("system:otherInfo:export")
    @Log(title = "其余相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/exportOtherInfoBase")
    @ResponseBody
    public AjaxResult exportOtherInfoBase(PersonOtherInfo personOtherInfo)
    {
        List<PersonOtherInfo> list = personOtherInfoService.selectPersonOtherInfoInBaseList(personOtherInfo);
        ExcelUtil<PersonOtherInfo> util = new ExcelUtil<PersonOtherInfo>(PersonOtherInfo.class);
        return util.exportExcel(list, "其余相关信息数据");
    }

    /**
     * 新增其余相关信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存其余相关信息
     */
    @RequiresPermissions("system:otherInfo:add")
    @Log(title = "其余相关信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PersonOtherInfo personOtherInfo)
    {
        return toAjax(personOtherInfoService.insertPersonOtherInfo(personOtherInfo));
    }

    /**
     * 修改其余相关信息
     */
    @RequiresPermissions("system:otherInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PersonOtherInfo personOtherInfo = personOtherInfoService.selectPersonOtherInfoById(id);
        mmap.put("personOtherInfo", personOtherInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存其余相关信息
     */
    @RequiresPermissions("system:otherInfo:edit")
    @Log(title = "其余相关信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PersonOtherInfo personOtherInfo)
    {
        return toAjax(personOtherInfoService.updatePersonOtherInfo(personOtherInfo));
    }

    /**
     * 删除其余相关信息
     */
    @RequiresPermissions("system:otherInfo:remove")
    @Log(title = "其余相关信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(personOtherInfoService.deletePersonOtherInfoByIds(ids));
    }
}
